<template>
  <div>
    <list-page :data="listPageConfig">
      <template v-slot:tableColumn>
        <el-table-column
          align="center"
          label="季度"
          prop="quarter"
          show-overflow-tooltip
        />
        <el-table-column
          align="center"
          label="科室"
          prop="department"
          show-overflow-tooltip
        />
        <el-table-column
          align="center"
          label="姓名"
          prop="users_name"
          show-overflow-tooltip
        />
        <el-table-column
          align="center"
          label="工作小结"
          prop="orgPostUserWorkSum_file"
          show-overflow-tooltip
        >
          <template v-slot="{ row }">
            <file
              :file="row.orgPostUserWorkSum_file"
              :file-name="row.orgPostUserWorkSum_fileName"
            />
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="添加时间"
          prop="orgPostUserWorkSum_addTime"
          show-overflow-tooltip
        />
        <el-table-column align="center" label="操作">
          <template v-slot="{ row }">
            <el-button type="text" size="medium" @click="mark(row)"
              >打分</el-button
            >
          </template>
        </el-table-column>
      </template>
    </list-page>
  </div>
</template>

<script>
import tableMixin from '@/mixin/tablePageMixin'
import ListPage from '@/views/_common/ListPage'
import File from '@/components/File'
import { request } from '@/api/request'

export default {
  name: 'MarkList',

  components: {
    ListPage,
    File
  },

  mixins: [tableMixin],

  props: {
    listPageName: {
      type: String,
      default: null
    }
  },

  data() {
    return {}
  },

  computed: {
    listPageConfig() {
      return {
        pageLoading: this.config.operating,
        dataLoading: this.config.loading,
        buttons: [],
        table: {
          props: { data: this.tableData },
          on: { 'row-click': this.rowClick }
        },
        pagination: {
          props: { model: this.searchForm },
          on: {
            'current-change': this.pageChange,
            'size-change': this.pageSizeChange
          }
        }
      }
    }
  },

  methods: {
    mark({ id, users_name }) {
      this.$router.push(
        `/personalCenter/${this.listPageName}/mark/${id}/${encodeURIComponent(
          users_name
        )}`
      )
    },

    search() {
      if (this.config.loading) return
      this.config.loading = true
      request(
        'personal/needToScoreWorkSummary/index',
        { p: this.searchForm.page, limit: this.searchForm.pageSize },
        (res) => {
          this.searchForm.total = res.data.count
          this.tableData = res.data._list
        }
      ).finally(() => {
        this.config.loading = false
        this.tableData = [
          {
            id: 123,
            quarter: '2021第二季度',
            department: '科室1',
            users_name: '唐老鸭'
          }
        ]
      })
    }
  }
}
</script>
